package com.jcl.core.utils;

import java.util.Random;
import java.util.UUID;

/**
 * @ClassName CodeUtils

 * @Author yyliu
 * @Date 2018/9/18 10:12
 * @Version 1.0
 **/
public class CodeUtils {

    public static String generateVerificationCodeDefault(){

        return generateVerificationCode(6);
    }

    public static String generateVerificationCode(Integer len){
        if(null == len){
            len = 6;
        }
        Random random = new Random();
        StringBuffer buffer = new StringBuffer();
        while(buffer.length() < len){
            buffer.append(random.nextInt(8) + 1);
        }
        return buffer.toString();
    }

    public static String getUuidKey(){

        return UUID.randomUUID().toString().replaceAll("-","").toUpperCase();
    }

    public static void main(String[] args) {
        for(int i = 0; i < 10; i ++){
            System.out.println(getUuidKey());
        }
    }
}
